home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / DELDUP.AML < prev    next >
Text File  |  1996-07-17  |  2KB  |  68 lines

  1. //--------------------------------------------------------------------
  2. // DELDUP.AML
  3. // Delete Duplicate Lines, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro deletes contiguous duplicate lines in the current edit
  6. // window. The total number of lines removed is displayed. Note: this
  7. // macro will run faster if Undo is turned Off on the Set menu.
  8. //
  9. // Usage:
  10. //
  11. // Select this macro from the Macro List (on the Macro menu), or run it
  12. // from the macro picklist <shift f12>.
  13. //--------------------------------------------------------------------
  14.  
  15. include bootpath "define.aml"
  16.  
  17. variable lastline, shownext
  18.  
  19. // test for edit windows
  20. if not wintype? "edit" then
  21.   msgbox "Edit windows only!"
  22.   return
  23. end
  24.  
  25. oldsize = getlines          // save the number of lines in file
  26. undobegin                   // group this together as one undoable action
  27. row 1                       // goto the first line
  28. lasttext = gettext          // get first line in variable lasttext
  29.  
  30. if down then                // goto the next line
  31.  
  32.   // do for all lines
  33.   loop
  34.  
  35.     // show progress every 150 lines
  36.     if getrow > shownext then
  37.       say (getrow)
  38.       shownext = shownext + 150
  39.     end
  40.  
  41.     // if this line is the same as the last line then delete it
  42.     if gettext == lasttext then
  43.  
  44.       // delete line and test for end-of-file
  45.       if delline > getrow then
  46.         break
  47.       end
  48.  
  49.     // ..otherwise save line text for the next comparision
  50.     // and goto the next line
  51.     else
  52.       lasttext = gettext
  53.       if not down then
  54.         break
  55.       end
  56.     end
  57.  
  58.   end
  59.  
  60. end
  61. breakoff
  62.  
  63. undoend                       // end of undoable group
  64. display                       // update display
  65.  
  66. // tell the user how many lines were removed
  67. say  (thousands oldsize - getlines) + " lines were removed"
  68.